package com.aaa.system.controller;


import com.aaa.system.entity.User;
import com.aaa.system.service.IUserService;
import com.aaa.system.vo.Result;
import com.aaa.system.vo.UserVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author 闫克起
 * @since 2023-06-20
 */
@RestController
@RequestMapping("/system/user")
public class UserController {
    @Autowired
    private IUserService userService;
    @PostMapping("/list")
    public Result list(Integer current, Integer pageSize,@RequestBody UserVo userVo){
        IPage<User> page=new Page<>(current,pageSize);
        QueryWrapper<User> wrapper=new QueryWrapper<>();
        //只能String
        if(StringUtils.hasText(userVo.getUsername())){
             wrapper.like("username",userVo.getUsername());
        }
        if(userVo.getStatus()!=null){
             wrapper.eq("is_deleted",userVo.getStatus());
        }
        IPage<User> page1 = userService.page(page, wrapper);
        return new Result(200,"查询用户成功",page1);
    }
}





















